package com.lcq.gulimall.seckill.utils;

import com.lcq.gulimall.seckill.vo.SeckillSkuRelationEntity;

import java.util.Date;

public class SeckillUtils {
    public static final String SESSION_CACHE_PREFIX = "seckill:sessions:";

    public static final String SKUKILL_CACHE_PREFIX = "seckill:skus:";

    public static final String SKUSTOCK_SEMAPHONE = "seckill:stock:"; // +商品随机码

    public static String getSecSessionKey(Date startDate,Date endDate){
        long startTime = startDate.getTime();
        long endTime = endDate.getTime();
        String key =SESSION_CACHE_PREFIX+startTime+"_"+endTime;
        return key;
    }

    public static String getSecSkuKey(SeckillSkuRelationEntity SkuRe){
        return SkuRe.getPromotionSessionId() + "_" + SkuRe.getSkuId();
    }

    public static String getSecSkuSemKey(String code){
        return SKUSTOCK_SEMAPHONE + "_" + code;
    }

}
